/***** UPDATE COMPANY***/
USE [Clinic]
GO
/****** Object:  StoredProcedure [dbo].[UpdateCompany]    Script Date: 12/30/2007 13:54:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_UpdateCompany]
	(
	@companyID int,
	@companyName nvarchar(50),
	@bULSTAT nvarchar(50),
	@mOL nvarchar(30),
	@city nvarchar(50),
	@address nvarchar(50),
	@postCode nvarchar(6),
	@phone nvarchar(15),
	@invoiceAddress nvarchar(80),
	@date smalldatetime
	)
AS
	/* SET NOCOUNT ON */
	UPDATE Company
	SET 	
	CompanyName = @companyName ,
	BULSTAT = @bULSTAT,
	MOL = @mOL,
	City = @city,
	Address = @address,
	PostCode = @postCode,
	Phone = @phone,
	InvoiceAddress = @invoiceAddress,
	Date = @date
	WHERE CompanyID = @companyID
	RETURN


/***** GET COMPANY***/
USE [Clinic]
GO
/****** Object:  StoredProcedure [dbo].[up_GetCompany]    Script Date: 12/30/2007 13:54:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetCompany]
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
	/* SET NOCOUNT ON */
	SELECT * FROM Company
	RETURN


/***** DELETE COMPANY***/
USE [Clinic]
GO
/****** Object:  StoredProcedure [dbo].[up_DeleteCompany]    Script Date: 12/30/2007 13:53:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DeleteCompany]
	
	(
	@companyID int
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM COMPANY 
	 WHERE CompanyID = @companyID
	RETURN

/***** CREATE COMPANY***/
USE [Clinic]
GO
/****** Object:  StoredProcedure [dbo].[up_CreateCompany]    Script Date: 12/30/2007 13:53:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[CreateCompany]
	
	(
	@companyName nvarchar(50),
	@bULSTAT nvarchar(50),
	@mOL nvarchar(30),
	@city nvarchar(50),
	@address nvarchar(50),
	@postCode nvarchar(6),
	@phone nvarchar(15),
	@invoiceAddress nvarchar(80)
	)
	
AS
	/* SET NOCOUNT ON */
	INSERT INTO Company(
	CompanyName,
	BULSTAT,
	MOL,
	City,
	Address,
	PostCode,
	Phone,
	InvoiceAddress,
	Date
	)
	
	VALUES
	(
	@companyName,
	@bULSTAT,
	@mOL,
	@city,
	@Address,
	@postCode,
	@phone,
	@invoiceAddress,
	GETDATE()
	);
	
	SELECT SCOPE_IDENTITY()
	RETURN
